<%--
  Created by IntelliJ IDEA.
  User: 1234
  Date: 2018/5/3
  Time: 9:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<script language='JavaScript' src='/static/js/jquery.min.js'></script>
<script language='JavaScript' src='/static/layer/layer.js'></script>
<center>
    <div style='font-size:20px;margin-top:30px;'><b id="msg"></b></div>
    <div style='font-size:20px;margin-top:30px;'>
        <button onclick='errReset(1)' style='cursor:pointer;'>练习错题</button>&nbsp;<button onclick='errReset(2)'
                                                                                         style='cursor:pointer;'>一键清空
    </button>
    </div>
</center>
</body>
<script>
    var count;
    $(function () {
        $.get("/error/count", {}, function (msg) {
            count = msg["count"];
            $("#msg").html("您有" + msg["count"] + "道错题");
        }, "json");
    });
    function errReset(type) {
        if(type==2) {
            $.post("/error", {_method:"delete"}, function (msg) {
                if(msg['status']=="success"){
                    layer.msg("删除成功",{icon: 1,time:2000});
                    $("#msg").html("您有" + 0 + "道错题");
                }else {
                    layer.msg("删除失败",{icon: 2,time:2000});
                }
            }, "json");
        }else {
            if(count>0){
                window.parent.exportData("/toTemprorary/1-3-test.html");
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index);
            }else {
                layer.msg("您没有错题哦!",{icon: 1,time:2000});
            }

        }
    }
</script>
</html>
